package OldCode;
/*
 * Created on Nov 7, 2003
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
import java.util.*;

/**
 * @author sszhao
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class MousePath {
	private ArrayList moXs, moYs;
	private int miIndex;
	public MousePath(){
		moXs = new ArrayList();
		moYs = new ArrayList();
		miIndex = -1;
	}
	
	public int addPoint(int x, int y){
		moXs.add(new Integer(x));
		moYs.add(new Integer(y));
		miIndex++;
		return miIndex;
	}
	
	public int[] getPoint(int position){
		if(position > miIndex) return null;
		else{
		
		int[] point = new int[2];
		point[0] =((Integer) moXs.get(position)).intValue();
		point[1] = ((Integer) moYs.get(position)).intValue();
		return point;
		}
	}
	
	public void reset(){
		moXs = new ArrayList();
		moYs = new ArrayList();
		miIndex = -1;
	}
	
	public double getTotalDistance(){
		double totalDistance = 0.0;
		for(int i=0; i< miIndex; i++){
			int[] point1 = getPoint(i);
			int[] point2 = getPoint(i+1);
			totalDistance +=G.intPointDistance(point1[0],point1[1], point2[0], point2[1]);
		}
		return totalDistance;
	}
	
}
